/**
 * Deep Flattening Tool
 */

const steamrollArray = arr => {
  let newArr = [];
  // if (arr.every(
  //   item => !Array.isArray(item)
  // )) return arr;

  for (const item of arr) {
    if (Array.isArray(item)) newArr = newArr.concat(steamrollArray(item));
    else newArr.push(item);
  }
  return newArr;
}

let arr = [1, 2, 3];
arr = [[1], [], [2, [3]]];
arr = [1, {"foo": "bar"}, [2]];
console.log(steamrollArray(
  arr
));
